package common

import (
	"github.com/gin-gonic/gin"
	"ruoyi-go/internal/framework/utils/rest"
	"ruoyi-go/internal/web/common/service"
)

// RegisterRouterForCaptcha 验证码相关的路由注册
func RegisterRouterForCaptcha(g *gin.Engine) {
	g.GET("/captchaImage", func(c *gin.Context) { // 获取验证码
		captcha, err := service.GetCaptcha()
		if err != nil {
			rest.Fail(err).Send(c)
			return
		}
		rest.Success().With("captcha", captcha.Code).With("uuid", captcha.Uuid).With("img", captcha.Img).With("captchaEnabled", captcha.Enabled).Send(c)
	})
}
